package com.lxh.lxhcrm.model.pojos;

import javax.persistence.*;
import java.sql.Date;
import java.util.List;
import java.util.Objects;

/**
 * 申请采购抬头表
 */
@Entity
@Table(name = "app_cai", schema = "lxh_crm", catalog = "")
public class AppCai {
    private int appCaiId;       //抬头表id
    private String appCaiDan;   //申请采购单号
    private Date appDate;       //申请日期
    private String caiSite;     //采购地点
    private Double appTotal;    //总价
    private Integer appState;   //0.待审核 1.通过 2.未通过
    private String remark;      //申请采购备注

    private Emp emp;
    private Supplier supplier;
    private List<AppDetail> appDetail;

    @ManyToOne
    @JoinColumn(name="supplier_id")
    public Supplier getSupplier() {
        return supplier;
    }

    public void setSupplier(Supplier supplier) {
        this.supplier = supplier;
    }

    @ManyToOne
    @JoinColumn(name="emp_id",referencedColumnName = "emp_id")
    public Emp getEmp() {
        return emp;
    }

    public void setEmp(Emp emp) {
        this.emp = emp;
    }

    @OneToMany(mappedBy = "appCai")
    public List<AppDetail> getAppDetail() {
        return appDetail;
    }

    public void setAppDetail(List<AppDetail> appDetail) {
        this.appDetail = appDetail;
    }

    @Id
    @Column(name = "app_cai_id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getAppCaiId() {
        return appCaiId;
    }

    public void setAppCaiId(int appCaiId) {
        this.appCaiId = appCaiId;
    }

    @Basic
    @Column(name = "app_cai_dan", nullable = true, length = 40)
    public String getAppCaiDan() {
        return appCaiDan;
    }

    public void setAppCaiDan(String appCaiDan) {
        this.appCaiDan = appCaiDan;
    }

    @Basic
    @Column(name = "app_date", nullable = true)
    public Date getAppDate() {
        return appDate;
    }

    public void setAppDate(Date appDate) {
        this.appDate = appDate;
    }

    @Basic
    @Column(name = "cai_site", nullable = true, length = 40)
    public String getCaiSite() {
        return caiSite;
    }

    public void setCaiSite(String caiSite) {
        this.caiSite = caiSite;
    }

    @Basic
    @Column(name = "app_total", nullable = true, precision = 0)
    public Double getAppTotal() {
        return appTotal;
    }

    public void setAppTotal(Double appTotal) {
        this.appTotal = appTotal;
    }

    @Basic
    @Column(name = "app_state", nullable = true)
    public Integer getAppState() {
        return appState;
    }

    public void setAppState(Integer appState) {
        this.appState = appState;
    }

    @Basic
    @Column(name = "remark", nullable = true, length = 200)
    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AppCai appCai = (AppCai) o;
        return appCaiId == appCai.appCaiId &&
                Objects.equals(appCaiDan, appCai.appCaiDan) &&
                Objects.equals(appDate, appCai.appDate) &&
                Objects.equals(caiSite, appCai.caiSite) &&
                Objects.equals(appTotal, appCai.appTotal) &&
                Objects.equals(appState, appCai.appState) &&
                Objects.equals(remark, appCai.remark) &&
                Objects.equals(emp, appCai.emp) &&
                Objects.equals(supplier, appCai.supplier) &&
                Objects.equals(appDetail, appCai.appDetail);
    }

    @Override
    public int hashCode() {
        return Objects.hash(appCaiId, appCaiDan, appDate, caiSite, appTotal, appState, remark, emp, supplier, appDetail);
    }
}